package src;

/**
 * 链表队列
 */
public class LinkedQueue<E> implements Queue<E> {

    private LinkedList<E> list;

    public LinkedQueue(){
        list = new LinkedList<>();
    }
    @Override
    public int getSize() {
        return list.getSize();
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }

    @Override
    public void enQueue(E e) {
        list.addLast(e);
    }

    @Override
    public E deQueue() {
        return list.removeFirst();
    }

    @Override
    public E getFront() {
        return list.getLast();
    }

    @Override
    public String toString() {
        StringBuilder res = new StringBuilder();
        res.append("Queue: <-- ");
        res.append(list);
        res.append(" <--");
        return res.toString();
    }
}